// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file is generated.
#ifndef VULKAN_WRAPPER_H
#define VULKAN_WRAPPER_H

// 对于鸿蒙平台，使用系统提供的 Vulkan 支持
#ifdef VK_USE_PLATFORM_OHOS
#include <vulkan/vulkan.h>
#include <native_window/external_window.h>

// 鸿蒙扩展定义
#ifndef VK_KHR_OHOS_SURFACE_EXTENSION_NAME
#define VK_KHR_OHOS_SURFACE_EXTENSION_NAME "VK_KHR_ohos_surface"
#endif

// 鸿蒙表面创建信息结构体定义
#ifndef VK_STRUCTURE_TYPE_OHOS_SURFACE_CREATE_INFO_KHR
#define VK_STRUCTURE_TYPE_OHOS_SURFACE_CREATE_INFO_KHR ((VkStructureType)1000282000)
#endif

// 鸿蒙表面创建信息结构体
typedef struct VkOhosSurfaceCreateInfoKHR {
    VkStructureType    sType;
    const void*        pNext;
    VkFlags            flags;
    OHNativeWindow*    window;
} VkOhosSurfaceCreateInfoKHR;

// 鸿蒙表面创建函数指针类型定义
typedef VkResult (VKAPI_PTR *PFN_vkCreateOhosSurfaceKHR)(
    VkInstance                        instance,
    const VkOhosSurfaceCreateInfoKHR* pCreateInfo,
    const VkAllocationCallbacks*      pAllocator,
    VkSurfaceKHR*                     pSurface);

// 鸿蒙扩展函数
extern PFN_vkCreateOhosSurfaceKHR vkCreateOhosSurfaceKHR;

/* Initialize the Vulkan function pointer variables declared in this header.
 * Returns 0 if vulkan is not available, non-zero if it is available.
 */
int InitVulkan(void);

#else
// 其他平台使用动态加载
#define VK_NO_PROTOTYPES 1
#include <vulkan/vulkan_core.h>

// 为了兼容性，在非鸿蒙平台也定义鸿蒙相关类型
#ifndef VK_STRUCTURE_TYPE_OHOS_SURFACE_CREATE_INFO_KHR
#define VK_STRUCTURE_TYPE_OHOS_SURFACE_CREATE_INFO_KHR ((VkStructureType)1000282000)
#endif

// 前向声明OHNativeWindow类型（非鸿蒙平台不会实际使用）
struct OHNativeWindow;

// 鸿蒙表面创建信息结构体
typedef struct VkOhosSurfaceCreateInfoKHR {
    VkStructureType    sType;
    const void*        pNext;
    VkFlags            flags;
    struct OHNativeWindow*    window;
} VkOhosSurfaceCreateInfoKHR;

// 鸿蒙表面创建函数指针类型定义
typedef VkResult (VKAPI_PTR *PFN_vkCreateOhosSurfaceKHR)(
    VkInstance                        instance,
    const VkOhosSurfaceCreateInfoKHR* pCreateInfo,
    const VkAllocationCallbacks*      pAllocator,
    VkSurfaceKHR*                     pSurface);

/* Initialize the Vulkan function pointer variables declared in this header.
 * Returns 0 if vulkan is not available, non-zero if it is available.
 */
int InitVulkan(void);

// VK_core - 函数指针声明（仅用于非鸿蒙平台）
extern PFN_vkCreateInstance vkCreateInstance;
extern PFN_vkDestroyInstance vkDestroyInstance;
extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
extern PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
extern PFN_vkCreateDevice vkCreateDevice;
extern PFN_vkDestroyDevice vkDestroyDevice;
extern PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
extern PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
extern PFN_vkGetDeviceQueue vkGetDeviceQueue;

// VK_KHR_surface
extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;

// VK_KHR_swapchain
extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
extern PFN_vkQueuePresentKHR vkQueuePresentKHR;

// 其他平台的表面创建函数
#ifdef VK_USE_PLATFORM_ANDROID_KHR
extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
#endif

#ifdef VK_USE_PLATFORM_WIN32_KHR
extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
#endif

// 鸿蒙扩展函数声明（在所有平台上都需要）
extern PFN_vkCreateOhosSurfaceKHR vkCreateOhosSurfaceKHR;

#endif // VK_USE_PLATFORM_OHOS

#endif // VULKAN_WRAPPER_H
